const { Model, DataTypes } = require("sequelize");
const { sequelize } = require("../config/mysql_config");

class Service extends Model {}

Service.init(
    {
        id: { type: DataTypes.INTEGER.UNSIGNED, autoIncrement: true, primaryKey: true },
        serviceName: {
            type: DataTypes.STRING(30),
            allowNull: true,
            comment: "服务名称",
        },
        advisorId: {
            type: DataTypes.BIGINT.UNSIGNED,
            allowNull: false,
            comment: "顾问ID",
        },
        serviceType: {
            //总长度为10，2位小数
            type: DataTypes.TINYINT.UNSIGNED,
            allowNull: true,
            comment: "服务类型: 1=24h Delivered Text Reading, 2=24h Delivered Audio Reading, 3=24h Delivered Video Reading, 4=Live Text Chat",
        },
        price: {
            type: DataTypes.DECIMAL(10, 2),
            allowNull: false,
            defaultValue: 0,
            comment: "服务价格(美元），这里设金币和美金的比率时100:1",
        }
    },
    {
        sequelize,
        modelName: "Service",
        tableName: "services", // 表名
        timestamps: true,
        underscored: true, // 启用下划线命名（字段与模型自动转换）
        comment: "顾问提供的服务表",
    }
);

module.exports = Service;